package homework;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;

public class Work05 {
    //1、使用从键盘输入三句话，用PrintStream打印到一个words.txt文件中
    //
    //	2、再用Scanner一行一行读取显示

    public static void main(String[] args) throws FileNotFoundException {
        //1、使用从键盘输入三句话，用PrintStream打印到一个words.txt文件中
        PrintStream ps = new PrintStream("day09-code/src/homework/words.txt");
        //2、键盘输入
        Scanner sc = new Scanner(System.in);
        //3、打印
        ps.println(sc.nextLine());
        ps.println(sc.nextLine());
        ps.println(sc.nextLine());
        ps.close();
        //3、用Scanner一行一行读取显示
        Scanner scanner = new Scanner(new File("day09-code/src/homework/words.txt"));
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}
